<?php

namespace App\Models;

use App\Models\Traits\ProductSkuTrait;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Factories\HasFactory;

/**
 * App\Models\ProductSku
 *
 * @property int $id
 * @property int $product_id belongs to this product
 * @property string|null $name name of sku
 * @property string|null $brief description of sku
 * @property string|null $pic sku cover picture
 * @property array|null $attr_value
 * @property string|null $attr_value_index
 * @property string|null $price_cost cost price of sku
 * @property string|null $price normal selling price of sku
 * @property string|null $price_vip member price of sku
 * @property int $stock sku stock number
 * @property \Illuminate\Support\Carbon|null $created_at
 * @property \Illuminate\Support\Carbon|null $updated_at
 * @property-read \App\Models\Product $product
 * @method static \Database\Factories\ProductSkuFactory factory(...$parameters)
 * @method static \Illuminate\Database\Eloquent\Builder|ProductSku newModelQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|ProductSku newQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|ProductSku query()
 * @method static \Illuminate\Database\Eloquent\Builder|ProductSku whereAttrValue($value)
 * @method static \Illuminate\Database\Eloquent\Builder|ProductSku whereAttrValueIndex($value)
 * @method static \Illuminate\Database\Eloquent\Builder|ProductSku whereBrief($value)
 * @method static \Illuminate\Database\Eloquent\Builder|ProductSku whereCreatedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|ProductSku whereId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|ProductSku whereName($value)
 * @method static \Illuminate\Database\Eloquent\Builder|ProductSku wherePic($value)
 * @method static \Illuminate\Database\Eloquent\Builder|ProductSku wherePrice($value)
 * @method static \Illuminate\Database\Eloquent\Builder|ProductSku wherePriceCost($value)
 * @method static \Illuminate\Database\Eloquent\Builder|ProductSku wherePriceVip($value)
 * @method static \Illuminate\Database\Eloquent\Builder|ProductSku whereProductId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|ProductSku whereStock($value)
 * @method static \Illuminate\Database\Eloquent\Builder|ProductSku whereUpdatedAt($value)
 * @mixin \Eloquent
 * @property string|null $code product sku number
 * @method static \Illuminate\Database\Eloquent\Builder|ProductSku whereCode($value)
 * @property string|null $gold_beans give gold beans after buying this product
 * @method static \Illuminate\Database\Eloquent\Builder|ProductSku whereGoldBeans($value)
 */
class ProductSku extends Model
{
    use HasFactory, ProductSkuTrait;
	
	protected $guarded = ['id'];
	
	protected $casts = [
		'attr_value' => 'json',
	];
	
	public function product()
	{
		return $this->belongsTo(Product::class);
	}
}
